var t = require("../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Page({
    data: {
        nowTimes: new Date(),
        list: [],
        isLoadMore: !0,
        page: 1,
        last_page: 1,
        pageOptions: {},
        timeData: [],
        currentTime: 0,
        _arr: []
    },
    onLoad: function(t) {
        this.currentTime = parseInt(new Date().getTime() / 1e3), this.getData();
    },
    onChange: function(a) {
        this.data._arr[a.target.dataset.id] = t(t({}, a.detail), {}, {
            id: a.target.dataset.id
        }), this.setData({
            timeData: this.data._arr
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.goods-limit-set.frontend.controllers.index.index");
        a._postNetWork({
            url: e,
            data: {
                page: this.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    currentTime: parseInt(new Date().getTime() / 1e3),
                    list: e.data.list.data,
                    total_page: e.data.list.last_page,
                    isLoadMore: !0,
                    pageOptions: e.data.set
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.goods-limit-set.frontend.controllers.index.index");
            e += "&page=".concat(this.data.page), a._postNetWork({
                url: e,
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var i = e.data.list.data, o = t.data.list.concat(i);
                        t.setData({
                            list: o
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    gotoDetail: function(t) {
        var a = t.currentTarget.dataset.item.id;
        78 == t.currentTarget.dataset.item.plugin_id ? wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a + "&md=1"
        }) : wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});